{ INFORMATICS.MCCME.RU
  Problem statement: http://informatics.mccme.ru/moodle/mod/statements/view3.php?chapterid=1444
  Verdict: Accepted
}
uses SysUtils, Math;
 
var
	i,j,n,m,k,cur,x,y:longint;
	a:array[0..1010,0..1010] of shortint;
 
begin
reset(input,'input.txt');
rewrite(output,'output.txt');
fillchar(a,sizeof(a),0);
read(n,m,k);
for i:=1 to k do begin
	read(x,y);
	a[x][y]:=-1;
end;
for i:=1 to n do begin
	for j:=1 to m do
		if a[i][j]=-1 then write('* ') else begin
			cur:=0;
			if a[i-1][j-1]=-1 then inc(cur);
			if a[i-1][j]=-1 then inc(cur);
			if a[i-1][j+1]=-1 then inc(cur);
			if a[i][j-1]=-1 then inc(cur);
			if a[i][j+1]=-1 then inc(cur);
			if a[i+1][j-1]=-1 then inc(cur);
			if a[i+1][j]=-1 then inc(cur);
			if a[i+1][j+1]=-1 then inc(cur);
			write(cur,' ');
		end;
	writeln;
end;
end.
 